package es.dk.hl.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import es.dk.hl.model.HomeLinkModelLocator;

	public class FaceBook_ValidateLogin_Command implements ICommand
	{

		public function FaceBook_ValidateLogin_Command()
		{
		}
		
		public function execute(event:CairngormEvent):void {
			if (
				(!HomeLinkModelLocator.getInstance().facebook.is_connected) &&
				(HomeLinkModelLocator.getInstance().facebookUser == null) &&
				(
				(HomeLinkModelLocator.getInstance().statusFaceBookConnect == HomeLinkModelLocator.statusFaceBookConnect_LOGIN) ||
				(HomeLinkModelLocator.getInstance().statusFaceBookConnect == HomeLinkModelLocator.statusFaceBookConnect_CONNECT)
				)) {
					HomeLinkModelLocator.getInstance().facebookSessionUtil.validateLogin();
			} else {
				if 
					(HomeLinkModelLocator.getInstance().statusFaceBookConnect == HomeLinkModelLocator.statusFaceBookConnect_CONNECTED) {
						HomeLinkModelLocator.getInstance().facebookSessionUtil.logout();
				}
			}			
		}		
	}
}